﻿@model DLM.Domain.Model.User

<script type="text/javascript">
    $(document).ready(function () {
        $("#txtBirthday").datepicker({ dateFormat: "yy-mm-dd", changeMonth: true, changeYear: true, minDate: null, maxDate: null, yearRange: 'c-50:c+20', onSelect: function (dateText, inst) { calculateAge(dateText); } });

    });

    function calculateAge(dateText) {
        var now = new Date();
        var birthday = parseDate(dateText);
        var age = now.getFullYear() - birthday.getFullYear();
        $("#txtAge").val(age-1);
    }

    function parseDate(str) {
        if (typeof str == 'string') {
            var results = str.match(/^ *(\d{4})-(\d{1,2})-(\d{1,2}) *$/);
            if (results && results.length > 3)
                return new Date(parseInt(results[1]), parseInt(results[2]) - 1, parseInt(results[3]));
            results = str.match(/^ *(\d{4})-(\d{1,2})-(\d{1,2}) +(\d{1,2}):(\d{1,2}):(\d{1,2}) *$/);
            if (results && results.length > 6)
                return new Date(parseInt(results[1]), parseInt(results[2]) - 1, parseInt(results[3]), parseInt(results[4]), parseInt(results[5]), parseInt(results[6]));
            results = str.match(/^ *(\d{4})-(\d{1,2})-(\d{1,2}) +(\d{1,2}):(\d{1,2}):(\d{1,2})\.(\d{1,9}) *$/);
            if (results && results.length > 7)
                return new Date(parseInt(results[1]), parseInt(results[2]) - 1, parseInt(results[3]), parseInt(results[4]), parseInt(results[5]), parseInt(results[6]), parseInt(results[7]));
        }
        return null;
    }

   
       
</script>

@using (Html.BeginForm("Edit", "User", FormMethod.Post, new { enctype = "multipart/form-data",id="userinfo" }))
{
     <h3>
        基本资料</h3>
    <div class="tr clearfix">
        <label class="lb">
            <s></s>&nbsp;</label>
        <div class="info">
            @Html.ValidationSummary(true, "用户信息修改失败，请重试！")
        </div>
    </div>
    <div class="tr clearfix">
        <label class="lb">
            <s></s>姓名</label>
        <div class="info">
            @Html.HiddenFor(m => m.UserID)
            @Html.TextBoxFor(m => m.Name, new { @class = "text" })
            @Html.ValidationMessageFor(model => model.Name, "", new { @class = "va" })
            
        </div>
    </div>
    <div class="tr clearfix">
        <label class="lb">
            <s></s>头像</label>
        <div class="info">
            @if (Model != null && !string.IsNullOrEmpty(Model.Photo) && Model.Photo != "none_75_75.png")
            {
                <img src="@Url.Content("~/Files/Photos/" + Model.UserID + "/Title/" + Model.Photo)" alt="头像" />
            }
            else
            { 
                <img src="@Url.Content("~/Content/ad/none_75_75.png")" alt="头像" />
            }
            <div class="va">
                       务必上传真实照片，否则可能被毁被剥夺会员资格</div>
            <div class="va">
                       只允许不超过4MB大小的.JPEG格式的头像</div>
        </div>
    </div>
    <div class="tr clearfix">
        <label class="lb">
            <s></s>&nbsp;</label>
        <div class="info">
            <input type="file" name="uploadFile" />
              <span>请上传点击页面下方'提交修改'按钮方能生效</span>
        </div>
    </div>

    <div class="tr clearfix">
        <label class="lb">
            <s></s>性别</label>
        <div class="info">
            @{
            var list = new List<SelectListItem> 
                        { new SelectListItem { Text = "请选择", Value = "0" },
                            new SelectListItem { Text = "男", Value = "False" },
                            new SelectListItem { Text = "女", Value = "True" }
                        };


            if (Model.Gender.HasValue)
            {
                if (Model.Gender.Value)
                {
                    list[2].Selected = true;
                }
                else
                {
                    list[1].Selected = true;
                }
            }
                    
            }
            @Html.DropDownListFor(model => model.Gender, list, new { @class = "sel" })
            @Html.ValidationMessageFor(model => model.Gender, "", new { @class = "va error" })
        </div>
    </div>
    <div class="tr clearfix">
        <label class="lb">
            <s></s>出生年月</label>
        <div class="info">
            @Html.TextBoxFor(m => m.Birthday,new { @class = "text", id = "txtBirthday", maxlength = 22,value="@Model.Birthday.Value.ToShortDateString()" })
            @Html.ValidationMessageFor(m => m.Birthday, "", new { @class = "va error" })
        </div>
    </div>
          <div class="tr clearfix">
                <label class="lb">
                    <s></s>年龄</label>
                <div class="info">
                    @Html.TextBoxFor(m => m.Age, new { @class = "text", id = "txtAge", maxlength = 8 })
                    @Html.ValidationMessageFor(m => m.Age, "", new { @class = "va error" })
                </div>
            </div>
    <div class="tr clearfix">
        <label class="lb">
            <s></s>现居地</label>
        <div class="info">

          @*  @Html.TextBoxFor(m => m.Location, new { @class = "text t_3", maxlength = 18 })<br /><span>请用下来列表选择</span><br />*@
            @{ Html.RenderPartial("_CountrySelection", ViewData["CurrentLocation"] as DLM.Web.ViewModel.CountrySelectionPageView);}
            @Html.ValidationMessageFor(m => m.Location, "", new { @class = "va error" })
        </div>
    </div>
    <div class="tr clearfix">
        <label class="lb">
            <s></s>籍贯</label>
        <div class="info">
          @*  @Html.TextBoxFor(m => m.NativePlace, new { @class = "text t_3", maxlength = 18 })<br /><span>请用下来列表选择</span><br />*@
                @{ Html.RenderPartial("_NativeSelection", ViewData["CurrentNative"] as DLM.Web.ViewModel.NativeSelectionPageView);}
            @Html.ValidationMessageFor(m => m.NativePlace, "", new { @class = "va error" })
        </div>
    </div>
    <div class="tr clearfix">
        <label class="lb">
            <s></s>婚姻状况</label>
        <div class="info">
            @{
               List<SelectListItem> marriageList = new List<SelectListItem> 
                        { new SelectListItem { Text = "请选择", Value = "" },
                            new SelectListItem { Text = "未婚", Value = "未婚" },
                            new SelectListItem { Text = "已婚", Value = "已婚" },
                             new SelectListItem { Text = "离异", Value = "离异" }
                            
                };

               foreach (var marriageItem in marriageList)
               {
                   if (marriageItem.Text == Model.Marriage)
                   {
                       marriageItem.Selected = true;
                   }
               }
            }
            @Html.DropDownListFor(m => m.Marriage, marriageList, new { @class = "select" })
            @Html.ValidationMessageFor(model => model.Marriage, "", new { @class = "va error" })
        </div>
    </div>
    <div class="tr clearfix">
        <label class="lb">
            <s></s>身高</label>
        <div class="info">
            @Html.TextBoxFor(m => m.Stature, new { @class = "text t_1", maxlength = 10 })
            厘米
            @Html.ValidationMessageFor(m => m.Stature, "", new { @class = "va error" })
        </div>
    </div>
    <div class="tr clearfix">
        <label class="lb">
            <s></s>体重</label>
        <div class="info">
            @Html.TextBoxFor(m => m.Weight, new { @class = "text t_1", maxlength = 8 })公斤
            @Html.ValidationMessageFor(m => m.Weight, "", new { @class = "va error" })</div>
    </div>
    <div class="tr clearfix">
        <label class="lb">
            <s></s>学历</label>
        <div class="info">
            @{
               List<SelectListItem> eduList = new List<SelectListItem> 
    {new SelectListItem { Text = "请选择", Value = "" },
        new SelectListItem{ Text="高中",Value="高中"},
        new SelectListItem{ Text="大专",Value="大专"},
        
           new SelectListItem{Text="本科",Value="本科"},new SelectListItem{ Text="硕士",Value="硕士"},new SelectListItem{ Text="博士",Value="博士"},
    };
               foreach (var eduItem in eduList)
               {
                   if (Model.Education == eduItem.Value)
                   {
                       eduItem.Selected = true;
                   }
               }
            }
            @Html.DropDownListFor(m => m.Education, eduList, new { @class = "sel" })
            @Html.ValidationMessageFor(m => m.Education, "", new { @class = "va error" })
            @*@Html.TextBoxFor(m => m.Education, new { @class = "text" })*@</div>
    </div>
    <div class="tr clearfix">
        <label class="lb">
            <s></s>工作</label>
        <div class="info">
            @Html.TextBoxFor(m => m.Job, new { @class = "text", maxlength = 20 })
            @Html.ValidationMessageFor(m => m.Job, "", new { @class = "va error" })
        </div>
    </div>
    <div class="tr clearfix">
        <label class="lb">
            <s></s>月收入(税前)</label>
        <div class="info">
            @{
               List<SelectListItem> incomeList = new List<SelectListItem> 
    {new SelectListItem { Text = "请选择", Value = "" },
        new SelectListItem{ Text="5000及以下",Value="5000及以下"},
           new SelectListItem{Text="5000-10000",Value="5000-10000"},new SelectListItem{ Text="10000-20000",Value="10000-20000"},
           new SelectListItem{ Text="20000以上",Value="20000以上"}
    };
               foreach (var incomItem in incomeList)
               {
                   if (Model.Education == incomItem.Value)
                   {
                       incomItem.Selected = true;
                   }
               }
            }
            @Html.DropDownListFor(m => m.Income, incomeList, new { @class = "sel" })
            @Html.ValidationMessageFor(m => m.Income, "", new { @class = "va error" })
            @* @Html.TextBoxFor(m => m.Income, new { @class = "text" })*@</div>
    </div>
@*    <div class="tr clearfix">
        <label class="lb">
            <s></s>职位</label>
        <div class="info">
            @Html.TextBoxFor(m => m.Position, new { @class = "text", maxlength = 18 })
            @Html.ValidationMessageFor(m => m.Position, "", new { @class = "va error" })
        </div>
    </div>
    <div class="tr clearfix">
        <label class="lb">
            <s></s>行业</label>
        <div class="info">
            @Html.TextBoxFor(m => m.Industry, new { @class = "text", maxlength = 20})
            @Html.ValidationMessageFor(m => m.Industry, "", new { @class = "va error" })
        </div>
    </div>*@
    <div class="tr clearfix">
        <label class="lb">
            <s></s>房车状况</label>
        <div class="info">
            @{
               List<SelectListItem> carList = new List<SelectListItem> 
    {new SelectListItem{ Text="请选择",Value=""},
        new SelectListItem{ Text="有房有车",Value="有房有车"},
           new SelectListItem{Text="无房无车",Value="无房无车"},
           new SelectListItem{ Text="无房有车",Value="无房有车"},
           new SelectListItem{ Text="有房无车",Value="有房无车"}
    };
               foreach (var carItem in carList)
               {
                   if (carItem.Text == Model.Car)
                   {
                       carItem.Selected = true;
                   }
               }
            }
            @Html.DropDownListFor(m => m.Car, carList, new { @class = "sel" })
            @Html.ValidationMessageFor(m => m.Car, "", new { @class = "va error" })
            @* @Html.TextBoxFor(m => m.Car, new { @class = "text" })*@</div>
    </div>
    <div class="tr clearfix">
        <label class="lb">
            <s></s>父母状况</label>
        <div class="info">
            @{
               List<SelectListItem> faList = new List<SelectListItem> 
    {new SelectListItem{ Text="请选择",Value=""},
        new SelectListItem{ Text="均健在",Value="均健在"},
           new SelectListItem{Text="母亲健在",Value="母亲健在"},
           new SelectListItem{ Text="父亲健在",Value="父亲健在"},
           new SelectListItem{ Text="其他",Value="其他"}
    };
               foreach (var faItem in faList)
               {
                   if (Model.Parents == faItem.Value)
                   {
                       faItem.Selected = true;
                   }
               }
            }
            @Html.DropDownListFor(m => m.Parents, faList, new { @class = "sel" })
            @Html.ValidationMessageFor(m => m.Parents, "", new { @class = "va error" })
            @*@Html.TextBoxFor(m => m.Parents, new { @class = "text" })*@</div>
    </div>
    <h3>
        联系方式<a href="#"></a></h3>
    <div class="tr clearfix">
        <label class="lb">
            <s></s>QQ</label>
        <div class="info">
            @Html.TextBoxFor(m => m.IM, new { @class = "text", maxlength = 15 })
            @Html.ValidationMessageFor(m => m.IM, "", new { @class = "va error" })
        </div>
    </div>
    <div class="tr clearfix">
        <label class="lb">
            <s></s>手机号码</label>
        <div class="info">
            @Html.TextBoxFor(m => m.Phone, new { @class = "text", maxlength = 15 })
            @Html.ValidationMessageFor(m => m.Phone, "", new { @class = "va error" })
        </div>
    </div>
    <div class="tr clearfix">
        <label class="lb">
            <s></s>独白</label>
        <div class="info">
            @Html.TextAreaFor(m => m.Introduction, new { @class = "textarea", maxlength = 300 })
            @Html.ValidationMessageFor(m => m.Introduction, "", new { @class = "va error" })
        </div>
    </div>
    <div class="tr clearfix btn">
        <label class="lb">
            <s></s>&nbsp;</label>
        <div class="info">
            <input type="submit" value="" class="edit_info" /></div>
    </div>
}


